package com.wangyadong.hobby.schedule.jobtask.javasync.Reference.SoftReference;

import com.wangyadong.hobby.schedule.jobtask.javasync.Reference.CacheLoader;

import java.lang.ref.SoftReference;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * <p>
 *
 * @author <714037465@qq.com>
 * @since 2018/11/1614:00
 **/
public class SoftLRUCache<K, V> {

    private final LinkedList<K> linkedList = new LinkedList<>();

    private final int capacity;

    private final CacheLoader cacheLoader;

    public SoftLRUCache(int capacity, CacheLoader cacheLoader) {
        this.cacheLoader = cacheLoader;
        this.capacity = capacity;
    }

    private final Map<String, SoftReference<V>> cache = new HashMap<>();

    public void put(K k, V v) {
        if (linkedList.size() >= capacity) {
            K k1 = linkedList.removeFirst();
            cache.remove(k1);
        }
        if (linkedList.contains(k)) {

        }
    }
}
